#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i) 
#define mkp std::make_pair
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;
inline bool cmp(int x,int y){return x < y;}

const int N = 1e6+9;
const int inf = 1e9+9;
const double eps = 1e-7;
int _,n,m;
ll a[2*N],b[2*N],ans;
char ch[100];

inline int find(ll x){
    int p = 55;
    while(!(x & (1ll<<p)) && p >= 1) --p;
    return p;
}  

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef LOCAL //use "g++ xxx.cpp -DLOCAL"
        freopen("in.in", "r", stdin);
    #endif
    cin >> n >> m;
    rep(i,1,m){
        cin >> ch+1;
        rep(j,1,n) a[i] = (a[i] << 1) + (ch[j] == 'O');
    }
    rep(i,1,m){
        int p;
        while(1){
            p = find(a[i]);
            if(!b[p]){
                b[p] = a[i];
                break;
            } else {
                a[i] ^= b[p];
                if(p == 0) break;
                continue;
            }
        }
    }
    ans = 1;
    per(i,55,0) if(b[i]){ans <<= 1 , ans %= 2008;}
    if(ans == 1) ans = 0;
    cout << ans%2008 << "\n";
    return 0;
}